package mil.af.amc.adpetracker.web.actions.struts1.DrmoPackage;

import mil.af.amc.adpetracker.service.DrmoPackageService;
import mil.af.amc.adpetracker.web.actions.struts1.AbstractAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Action to delete a DRMO package
 *
 * TODO: Method Security
 * TODO: prevent deletion of someone else's package
 * TODO: prevent deletion of closed package
 *
 * @author TSgt Jason Ferguson
 */
public class DeleteDrmoPackageAction extends AbstractAction {

    private DrmoPackageService drmoPackageService;

    public void setDrmoPackageService(DrmoPackageService drmoPackageService) {
        this.drmoPackageService = drmoPackageService;
    }

    @Override
    public ActionForward execute(ActionMapping actionMapping,
                                 ActionForm actionForm,
                                 HttpServletRequest httpServletRequest,
                                 HttpServletResponse httpServletResponse) throws Exception {

        int id = Integer.parseInt(httpServletRequest.getParameter("id"));
        drmoPackageService.deletePackage(id);

        return actionMapping.findForward("success");

    }
}
